const request = require('request');
const {sys}=require('../config');


//用户登录
const data = { userId: 'ccp', password: 'ccp123456' };
exports.userLogin = () => new Promise((res, rej) => {
  request.post({ url: `${sys.testUrl}user/login`, form: data },
    (err, httpResponse, body) => {
      if (err) console.error(err);
      const data = JSON.parse(body);
      data.status;
      if (data.status === 0) {
        res({ Accept: '*/*',
          'Content-Type': 'application/json;charset=UTF-8',
          'Accept-Encoding': 'gzip, deflate',
          'Accept-Language': 'zh-CN,zh;q=0.8',
          Connection: 'keep-alive',
          Cookie: httpResponse.headers['set-cookie']
        });
      } else {
        console.log(data.msg);
        rej();
      }
    });
});
